﻿#pragma once
#include "DSP.h"

namespace yzrilyzr_dsp{
	ECLASS(Integrator, public DSP){
	public:
	u_sample value=0;
	u_sample deltaTime=0;
	Integrator();
	Integrator(u_sample initValue) : value(initValue){}
	u_sample procDsp(u_sample in)override{
		u_sample out=value + in * deltaTime;
		value=out;
		return out;
	}
	void init(u_sample_rate sampleRate)override{
		this->deltaTime=1.0 / sampleRate;
	}
	void resetMemory()override{
		value=0;
	}
	std::shared_ptr<DSP> cloneDSP()override{
		return std::make_shared < Integrator>();
	}
	void cloneParam(DSP * obj1)override{}
	yzrilyzr_lang::String toString()const override;
	};
}